<?php
/**
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/

function render_properties($node, $properties, $doc)
{
	$key_node = NULL;
	$property_keys = array_keys($properties);
	$property_value = NULL;
	foreach($property_keys as $key)
	{
		$property_value = $properties[$key];
		$key_node = $doc->createElement('property');
		$key_node-> setAttribute('key', $key);
		if ( !is_array($property_value) )
		{
			//$key_node-> setAttribute('value', $property_value);
			// this is changed to have an inner element rather than an attribute
			$valueNode = $doc-> createTextNode($property_value);

			$key_node->appendChild($valueNode);
		}
		else
		{
			render_properties($key_node, $property_value, $doc);
		}
		$node->appendChild($key_node);
	}
}

function render_containers($node, $containers, $doc)
{
	$key_node = NULL;
	$container_keys = array_keys($containers);
	$container_attributes = NULL;
	$value = NULL;
	foreach($container_keys as $key)
	{
		$key_node = $doc->createElement('container');
		$key_node-> setAttribute('id', $key);
		
		$container_attributes = $containers[$key];
		$attri_keys = array_keys($container_attributes);
		foreach ($attri_keys as $attri )
		{
			$value = $container_attributes[$attri];
			$key_node-> setAttribute($attri, $value );
		}
		$node->appendChild($key_node);
	}
}
?>